<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>食堂列表 - 校园食堂点评系统</title>
    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
    <link rel="stylesheet" th:href="@{/front/css/style.css}">
    <style>
        .hero_single {
            width: 100%;
            height: 350px;
            background: #4a90e2;
            color: #fff;
            text-align: center;
            padding: 80px 0;
            margin-bottom: 50px;
        }
        .hero_single h3 {
            font-size: 2.5rem;
            margin-bottom: 30px;
        }
        .canteen-box {
            margin-top: 30px;
            text-align: center;
        }
        .canteen-item {
            background: #fff;
            padding: 20px;
            border-radius: 10px;
            box-shadow: 0 2px 10px rgba(0,0,0,0.1);
            margin-bottom: 20px;
            transition: all 0.3s ease;
        }
        .canteen-item:hover {
            transform: translateY(-5px);
            box-shadow: 0 5px 20px rgba(0,0,0,0.15);
        }
        .canteen-item h3 {
            color: #333;
            margin: 10px 0;
            font-size: 24px;
        }
        .canteen-item p {
            color: #666;
            margin-bottom: 15px;
        }
        .canteen-item img {
            width: 100%;
            height: 200px;
            object-fit: cover;
            border-radius: 5px;
        }
        .main_title_3 {
            margin-bottom: 20px;
        }
        .main_title_3 h2 {
            font-size: 28px;
            color: #333;
            font-weight: 500;
            margin-bottom: 20px;
            position: relative;
            padding-bottom: 10px;
        }
        .main_title_3 h2:after {
            content: '';
            position: absolute;
            left: 50%;
            transform: translateX(-50%);
            bottom: 0;
            width: 50px;
            height: 3px;
            background: #4a90e2;
        }
        .lazy-load {
            opacity: 0;
            transition: opacity 0.3s ease-in;
        }
        .lazy-load.loaded {
            opacity: 1;
        }
    </style>
</head>
<body>
<div th:replace="front/common :: header"></div>

<section class="hero_single">
    <div class="wrapper">
        <div class="container">
            <h3>探索校园美食</h3>
            <p>发现各个食堂的特色美食，享受舌尖上的美味</p>
        </div>
    </div>
</section>

<div class="container canteen-box">
    <div class="main_title_3">
        <h2>校园食堂</h2>
    </div>
    <div class="row">
        <div class="col-lg-4" th:each="canteen : ${canteens}">
            <div class="canteen-item">
                <img th:src="${canteen.photo}" th:alt="${canteen.name}" class="lazy-load">
                <h3 th:text="${canteen.name}">食堂名称</h3>
                <div class="meta-info">
                    <p class="business-time" th:text="${'营业时间：' + canteen.businessTime}">营业时间</p>
                    <p class="view-count" th:text="${'访问量：' + canteen.viewSize}">访问量</p>
                    <p class="status" th:text="${canteen.status == 1 ? '营业中' : '休息中'}" 
                       th:class="${canteen.status == 1 ? 'status-open' : 'status-closed'}">状态</p>
                </div>
                <p th:text="${canteen.description}">食堂描述</p>
                <a th:href="@{'/canteen/' + ${canteen.id}}" class="btn_1">查看详情</a>
            </div>
        </div>
    </div>
</div>

<div th:replace="front/common :: footer"></div>

<!-- 添加图片延迟加载脚本 -->
<script>
document.addEventListener('DOMContentLoaded', function() {
    let lazyImages = [].slice.call(document.querySelectorAll("img.lazy-load"));

    if ("IntersectionObserver" in window) {
        let lazyImageObserver = new IntersectionObserver(function(entries, observer) {
            entries.forEach(function(entry) {
                if (entry.isIntersecting) {
                    let lazyImage = entry.target;
                    lazyImage.classList.add("loaded");
                    lazyImageObserver.unobserve(lazyImage);
                }
            });
        });

        lazyImages.forEach(function(lazyImage) {
            lazyImageObserver.observe(lazyImage);
        });
    }
});
</script>
</body>
</html> 